import 'package:base_plugin/base_plugin.dart';
import 'package:dio/dio.dart';

/// 邀请
class HttpInvitationService {
  /// 我的邀请
  static Future<Response> myInvitation() {
    return BaseConfig.httpBase.get('/api/invitations/me', {});
  }

  /// 公司邀请人
  static Future<Response> companyInvitedPeople() {
    return BaseConfig.httpBase.get('/api/invitations/company', {});
  }

  //接受邀请
  static Future<Response> acceptInvited(List<String> companyIds, List<String> unselectedCompanyIds) {
    return BaseConfig.httpBase.postJson('/api/invitations/accept', {
      'company_ids': companyIds,
      'unselected_company_ids': unselectedCompanyIds,
    });
  }

  //邀请好友
  static Future<Response> invite(List members) {
    return BaseConfig.httpBase.postJson('/api/v2/invitations/invite', {
      'members': members,
    });
  }

  // 已邀请的好友列表
  static Future<Response> invitationMembers(String enabled) {
    return BaseConfig.httpBase.get('/api/invitations/members', {
      'enabled': enabled,
    });
  }

  // 移除邀请
  static Future<Response> invitationRemove(int invitationId) {
    return BaseConfig.httpBase.postJson('/api/invitations/remove', {
      'invitation_id': invitationId,
    });
  }

  // 会员禁用
  static Future<Response> invitationDisable(int userId) {
    return BaseConfig.httpBase.postJson('/api/invitations/members/disable', {
      'user_id': userId,
    });
  }

  static Future<Response> invitationChangeRole(int userId, String role) {
    return BaseConfig.httpBase.postJson('/api/invitations/change_role', {'user_id': userId, 'role': role});
  }
}
